<template>
    <div>
        <!--<el-button type="warning" size="mini" id="audit"><i class="el-icon-finished"></i>审批</el-button>
    <el-button type="success" size="mini" id="printBtn"><i class="el-icon-printer"></i>打印</el-button>-->
        <div style=" float: right;margin-right: 20px;">
            <el-button type="warning" size="mini" id="audit" @click="Approval_eventShow()"><i
                    class="el-icon-finished"></i>审批
            </el-button>
            <br/>
            <el-button style="margin-top: 10px;" type="warning" size="mini" id="withdraw" @click="withdraw"><i
                    class="el-icon-back"></i>撤回
            </el-button>
            <br/>
            <!--            <el-button style="margin-top: 10px;" type="success" size="mini" id="printBtn" @click="Print()"-->
            <!--                       v-print="printObj"><i class="el-icon-printer"></i>打印-->
            <!--            </el-button>-->
            <el-button style="margin-top: 10px;" type="success" size="mini" id="printBtn" @click="onPrintClick('oper')">
                <i
                        class="el-icon-printer"></i>打印
            </el-button>
        </div>
        <form class="wrapper"  v-if="!printShow">
            <div class="header">
                <img src="/image/logo.jpg" /><label>固基行远，协晨悟通</label>
            </div>
            <h2 class="Title">固远晨通科技发展有限公司开具发票申请单</h2>

            <table class="report_audit" rules=all>
                <tr>
                    <td style="width:200px">部门</td>
                    <td style="width:300px">{{ _GetAllDepartmentById(dataDB.DepartmentId)}}</td>
                    <td>申请时间</td>
                    <td>{{dataDB.ApplyDate}}</td>
                </tr>
                <tr  >
                    <td>申请人</td>
                    <td>{{GetUserName(dataDB.ApplyUserId)}}</td>
                    <td>发票类型</td>
                    <td>{{GetInvoiceType(dataDB.InvoiceType)}}</td>
                </tr>
                <tr>
                    <td>项目</td>
                    <td colspan="3">{{GetProjectName(dataDB.ProjectId)}}</td>
                </tr>
                <tr>
                    <td colspan="4"><h4>甲方单位资料</h4></td>
                </tr>
                <tr>
                    <td>单位全称</td>
                    <td>{{GetCompanyName()}}</td>
                    <td>税号</td>
                    <td>{{GetDutyParagraph()}}</td>
                </tr>
                <tr>
                    <td>注册地址电话</td>
                    <td colspan="3">{{GetAddressPhone()}}</td>
                </tr>
                <tr>
                    <td>开户银行名称</td>
                    <td colspan="3">{{GetBankName()}}</td>
                </tr>
                <tr>
                    <td>银行账号</td>
                    <td>{{GetBankCardNumber()}}</td>
                    <td>联系人</td>
                    <td>{{(dataDB.ContactUser)}}</td>
                </tr>
                <tr>
                    <td colspan="4"><h4>开票内容</h4></td>
                </tr>
                <tr>
                    <td>开票内容</td>
                    <td>{{dataDB.Content}}</td>
                    <td>税率</td>
                    <td>{{dataDB.TaxRate}}%</td>
                </tr>
                <tr>
                    <td rowspan="2">本次金额</td>
                    <td>不含税金额：¥{{GetOutTax()}}</td>
                    <td>税额</td>
                    <td> ¥{{GetTaxAmount()}}</td>
                </tr>
                <tr>
                    <td>含税金额：¥ {{GetTotalPrice()}}</td>
                    <td>大写</td>
                    <td>{{_Arabia_To_SimplifiedChinese(dataDB.TotalPrice)}}</td>
                </tr>
                <tbody class="HistoryHtml"></tbody>
                <tr>
                    <td rowspan="2">累积金额</td>
                    <td>不含税金额：¥ {{GetAllOutTax()}}</td>
                    <td>税额</td>
                    <td> ¥{{GetAllTaxAmount()}}</td>
                </tr>
                <tr>
                    <td>含税金额：¥ {{GetAllInTax()}}</td>
                    <td>大写</td>
                    <td>{{_Arabia_To_SimplifiedChinese(dataDB.AllInTax)}}</td>
                </tr>
                <tr>
                    <td>发票备注</td>
                    <td colspan="3">{{dataDB.InvoiceRemark}}</td>
                </tr>
                <tr>
                    <td>合同总额及支付阶段说明</td>
                    <td colspan="3">{{dataDB.Remark}}</td>
                </tr>
                <tr>
                    <td>图片</td>
                    <td colspan="3">
                        <el-image v-for="v in imgArray"
                                  style="width: 100px; height: 100px; margin-left:10px"
                                  :src="v"
                        >
                        </el-image>
                    </td>
                </tr>
                <tbody id="auditPeople"></tbody>
            </table>

            <table class="report_audit" rules=all>
                <tr>
                    <td width="80">项目负责人</td>
                    <td></td>
                    <td width="70">审批人</td>
                    <td></td>
                    <td width="70">开票人</td>
                    <td></td>
                </tr>
            </table>

            <div class="author"><span>固远晨通科技发展有限公司制</span></div>
            <div id="Footer">
                <div><span style="margin-right: 100px;">固远晨通科技发展有限公司</span><span>网址：<a>www.guyuanct.com</a></span></div>
                <div><span>地址：成都西区大道199号成都模具工业园C1栋</span></div>
            </div>
        </form>

        <!--endprint-->
        <!--@*HTML会计部分*@-->
        <el-dialog :visible.sync="detailAccount_show" :append-to-body='true' width="40%" title="会计审批">
            <el-form label-width="120px">
                <el-form-item label="金额" prop="Money">
                    <el-input v-model="dataDB.ApprovalMoney"></el-input>
                </el-form-item>
                <div style="text-align:center">
                    <el-button type="success" @click="submitAccount()">确认</el-button>
                </div>
            </el-form>
        </el-dialog>


        <!--@*HTML出纳部分*@-->
        <el-dialog :visible.sync="detailCashier_show" :append-to-body='true' width="40%" title="出纳审批">
            <el-form label-width="120px" :model="dataDB">
                <el-row>
                    <el-col :offset="2" :span="9">
                        <el-form-item label="支付方式" prop="ModuleNumber">
                            <el-select required placeholder="请选择类型" v-model="dataDB.TransferMethod"
                                       @change="TransferMethodChange">
                                <el-option :value="0" label="请选择类型"></el-option>
                                <el-option :value="1" label="现金支付">现金支付</el-option>
                                <el-option :value="2" label="银行转账">银行转账</el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <div :style="detailCashierstyle">
                    <el-row>
                        <el-col :offset="2" :span="9">
                            <el-form-item label="银行选择" prop="FinanceBankId">
                                <el-select v-model="dataDB.FinanceBankId" filterable placeholder="银行选择"
                                           style="width:100%">
                                    <el-option :value="0" label="请选择银行"> 请选择</el-option>
                                    <el-option v-for="(v,k) in AllFinanceBankCard" :value="v.Id" :data-userid="v.Id"
                                               :label="v.CardName" v-text="v.CardName"/>
                                </el-select>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :offset="2" :span="9">
                            <el-form-item label="手续费" prop="ServiceCharge">
                                <el-input v-model="dataDB.ServiceCharge"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </div>
                <div style="text-align:center">
                    <el-button type="success" @click="submitCashier()">确认</el-button>
                </div>
            </el-form>
        </el-dialog>

        <!--审批部分-->
        <el-dialog v-if="AuditComment_show" :modal="false" :visible.sync="AuditComment_show" width="40%" title="审批"
                   :before-close="onClose">
            <AuditComment ref="AuditCommentRef" :approval-receipt="Approval_event" :approval="Approval"></AuditComment>
        </el-dialog>

        <el-dialog :visible.sync="printShow" :append-to-body='true' width="100%" title="打印" top="0px"
                   :before-close="onPrintclose">
            <el-row>
                <el-col :span="12">
                    <div style="width:230%;margin-left:-68%;transform: scale(0.4,0.4);margin-top: -435px;padding-top: 20px;border:1px black solid"
                         :class="{print_border:printObj.id === 'wrapper'}"
                         @click="onPrintClick('wrapper')">
                        <form class="wrapper" id="wrapper">
                            <div class="header">
                                <img src="/image/logo.jpg" /><label>固基行远，协晨悟通</label>
                            </div>
                            <h2 class="Title">固远晨通科技发展有限公司开具发票申请单</h2>

                            <table class="report_audit" rules=all>
                                <tr>
                                    <td style="width:200px">部门</td>
                                    <td style="width:300px">{{ _GetAllDepartmentById(dataDB.DepartmentId)}}</td>
                                    <td>申请时间</td>
                                    <td>{{dataDB.ApplyDate}}</td>
                                </tr>
                                <tr  >
                                    <td>申请人</td>
                                    <td>{{GetUserName(dataDB.ApplyUserId)}}</td>
                                    <td>发票类型</td>
                                    <td>{{GetInvoiceType(dataDB.InvoiceType)}}</td>
                                </tr>
                                <tr>
                                    <td>项目</td>
                                    <td colspan="3">{{GetProjectName(dataDB.ProjectId)}}</td>
                                </tr>
                                <tr>
                                    <td colspan="4"><h4>甲方单位资料</h4></td>
                                </tr>
                                <tr>
                                    <td>单位全称</td>
                                    <td>{{GetCompanyName()}}</td>
                                    <td>税号</td>
                                    <td>{{GetDutyParagraph()}}</td>
                                </tr>
                                <tr>
                                    <td>注册地址电话</td>
                                    <td colspan="3">{{GetAddressPhone()}}</td>
                                </tr>
                                <tr>
                                    <td>开户银行名称</td>
                                    <td colspan="3">{{GetBankName()}}</td>
                                </tr>
                                <tr>
                                    <td>银行账号</td>
                                    <td>{{GetBankCardNumber()}}</td>
                                    <td>联系人</td>
                                    <td>{{(dataDB.ContactUser)}}</td>
                                </tr>
                                <tr>
                                    <td colspan="4"><h4>开票内容</h4></td>
                                </tr>
                                <tr>
                                    <td>开票内容</td>
                                    <td>{{dataDB.Content}}</td>
                                    <td>税率</td>
                                    <td>{{dataDB.TaxRate}}%</td>
                                </tr>
                                <tr>
                                    <td rowspan="2">本次金额</td>
                                    <td>不含税金额：¥{{GetOutTax()}}</td>
                                    <td>税额</td>
                                    <td> ¥{{GetTaxAmount()}}</td>
                                </tr>
                                <tr>
                                    <td>含税金额：¥ {{GetTotalPrice()}}</td>
                                    <td>大写</td>
                                    <td>{{_Arabia_To_SimplifiedChinese(dataDB.TotalPrice)}}</td>
                                </tr>
                                <tbody class="HistoryHtml"></tbody>
                                <tr>
                                    <td rowspan="2">累积金额</td>
                                    <td>不含税金额：¥ {{GetAllOutTax()}}</td>
                                    <td>税额</td>
                                    <td> ¥{{GetAllTaxAmount()}}</td>
                                </tr>
                                <tr>
                                    <td>含税金额：¥ {{GetAllInTax()}}</td>
                                    <td>大写</td>
                                    <td>{{_Arabia_To_SimplifiedChinese(dataDB.AllInTax)}}</td>
                                </tr>
                                <tr>
                                    <td>发票备注</td>
                                    <td colspan="3">{{dataDB.InvoiceRemark}}</td>
                                </tr>
                                <tr>
                                    <td>合同总额及支付阶段说明</td>
                                    <td colspan="3">{{dataDB.Remark}}</td>
                                </tr>
                                <tr>
                                    <td>图片</td>
                                    <td colspan="3">
                                        <el-image v-for="v in imgArray"
                                                  style="width: 100px; height: 100px; margin-left:10px"
                                                  :src="v"
                                        >
                                        </el-image>
                                    </td>
                                </tr>
                                <tbody id="auditPeople"></tbody>
                            </table>

                            <table class="report_audit" rules=all>
                                <tr>
                                    <td width="80">项目负责人</td>
                                    <td></td>
                                    <td width="70">审批人</td>
                                    <td></td>
                                    <td width="70">开票人</td>
                                    <td></td>
                                </tr>
                            </table>

                            <div class="author"><span>固远晨通科技发展有限公司制</span></div>
                            <div id="Footer">
                                <div><span style="margin-right: 100px;">固远晨通科技发展有限公司</span><span>网址：<a>www.guyuanct.com</a></span></div>
                                <div><span>地址：成都西区大道199号成都模具工业园C1栋</span></div>
                            </div>
                        </form>
                    </div>
                </el-col>
                <el-col :span="12">
                    <div
                            style="width:150%;margin-left:-32%;transform: scale(0.6,0.6);margin-top: -135px;min-height: 100px;border:1px black solid"
                            :class="{print_border:printObj.id === 'routine'}" @click="onPrintClick('routine')">
                        <div id="routine" style="margin: 50px">
                            <div style="margin-top: 100px;width: 100%;text-align: center">
                                <span style="font-weight:bold;font-size: 30px;letter-spacing:20px">开具发票申请单</span>
                                <span style="margin-left: 20px;font-size: 20px;font-weight: bold">（固远晨通科技发展有限公司制）</span>
                            </div>
                            <table class="report_data" rules=all style="margin-top: 20px">
                                <thead style="border-color: #999999;text-align: left">
                                <tr>
                                    <td class="tableDataTh" colspan="3" style="text-align: center">
                                        所属事业部
                                    </td>
                                    <td class="tableDataTh" colspan="10" style="text-align: center">
                                        {{_GetAllDepartmentById(dataDB.DepartmentId)}}
                                    </td>
                                    <td class="tableDataTh" colspan="3" style="text-align: center">
                                        申请日期
                                    </td>
                                    <td class="tableDataTh" colspan="8" style="text-align: center">
                                        {{fmtDate(dataDB.ApplyDate)}}
                                    </td>
                                </tr>
                                <tr>
                                    <td class="tableDataTh" colspan="3" style="text-align: center">
                                        申请人
                                    </td>
                                    <td class="tableDataTh" colspan="5" style="text-align: center">
                                        {{ GetUserName(dataDB.ApplyUserId)}}
                                    </td>
                                    <td class="tableDataTh" colspan="5" style="text-align: center">
                                        发票类型
                                    </td>
                                    <td class="tableDataTh" colspan="11" style="text-align: center">
                                        <span>增值税专用发票 （ {{dataDB.InvoiceType === 1 ? '√' : ''}} ） </span>
                                        <span style="margin-left: 50px">增值税普通发票（  {{dataDB.InvoiceType === 2 ? '√' : ''}}  ）</span>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="tableDataTh" colspan="3" style="text-align: center">
                                        项目名称
                                    </td>
                                    <td class="tableDataTh" colspan="21" style="text-align: center">
                                        {{ GetProjectName(dataDB.ProjectId) }}
                                    </td>
                                </tr>
                                <tr>
                                    <td class="tableDataTh" colspan="24" style="text-align: center">
                                        <span style="font-weight:bold;letter-spacing:20px">甲方单位资料</span>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="tableDataTh" colspan="3" style="text-align: center">
                                        <span>单位全称</span>
                                    </td>
                                    <td class="tableDataTh" colspan="11" style="text-align: center">
                                        <span>{{GetCompanyName()}}</span>
                                    </td>
                                    <td class="tableDataTh" colspan="3" style="text-align: center">
                                        <span>税号</span>
                                    </td>
                                    <td class="tableDataTh" colspan="8" style="text-align: center">
                                        <span>{{GetDutyParagraph()}}</span>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="tableDataTh" colspan="3" style="text-align: center">
                                        <span>注册地址电话</span>
                                    </td>
                                    <td class="tableDataTh" colspan="21" style="text-align: center">
                                        <span>{{GetAddressPhone()}}</span>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="tableDataTh" colspan="3" style="text-align: center">
                                        <span>开户行银行名称</span>
                                    </td>
                                    <td class="tableDataTh" colspan="21" style="text-align: center">
                                        <span>{{GetBankName()}}</span>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="tableDataTh" colspan="3" style="text-align: center">
                                        <span>银行账号</span>
                                    </td>
                                    <td class="tableDataTh" colspan="11" style="text-align: center">
                                        <span>{{GetBankCardNumber()}}</span>
                                    </td>
                                    <td class="tableDataTh" colspan="3" style="text-align: center">
                                        <span>联系人</span>
                                    </td>
                                    <td class="tableDataTh" colspan="8" style="text-align: center">
                                        <span>{{dataDB.ContactUser}}</span>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="tableDataTh" colspan="24" style="text-align: center">
                                        <span style="font-weight:bold;letter-spacing:30px">开票内容</span>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="tableDataTh" colspan="3">
                                        <span>开票内容</span>
                                    </td>
                                    <td class="tableDataTh" colspan="9">
                                        <span>{{dataDB.Content}}</span>
                                    </td>
                                    <td class="tableDataTh" colspan="3">
                                        <span>税率</span>
                                    </td>
                                    <td class="tableDataTh" colspan="9">
                                        <span>{{dataDB.TaxRate}}%</span>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="tableDataTh" colspan="3" rowspan="2" style="text-align: center">
                                        <span>本次金额</span>
                                    </td>

                                    <td class="tableDataTh" colspan="9">
                                        <label class="tableTitle">不含税金额：</label>
                                        <span style="margin-left: 10px">￥{{ GetOutTax() }}</span>
                                    </td>
                                    <td class="tableDataTh" colspan="3">
                                        <span>税额</span>
                                    </td>
                                    <td class="tableDataTh" colspan="9">
                                        <span>￥{{GetTaxAmount()}}</span>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="tableDataTh" colspan="21">
                                        <label class="tableTitle">含税金额：</label>
                                        <span style="margin-left: 10px">￥{{ GetTotalPrice() }}</span>
                                        <label class="tableTitle" style="margin-left: 50px">人民币（大写）：</label>
                                        <span style="margin-left: 10px">{{ _Arabia_To_SimplifiedChinese(dataDB.TotalPrice) }}</span>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="tableDataTh" colspan="3" rowspan="2" style="text-align: center">
                                        <span>累计金额</span>
                                    </td>
                                    <td class="tableDataTh" colspan="9">
                                        <label class="tableTitle">不含税金额：</label>
                                        <span style="margin-left: 10px">￥{{ GetAllOutTax() }}</span>
                                    </td>
                                    <td class="tableDataTh" colspan="3">
                                        <span>税额</span>
                                    </td>
                                    <td class="tableDataTh" colspan="9">
                                        <span>￥{{GetAllTaxAmount()}}</span>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="tableDataTh" colspan="21">
                                        <label class="tableTitle">含税金额：</label>
                                        <span style="margin-left: 10px">￥{{ GetAllInTax() }}</span>
                                        <label class="tableTitle" style="margin-left: 50px">人民币（大写）：</label>
                                        <span style="margin-left: 10px">{{ _Arabia_To_SimplifiedChinese(dataDB.AllInTax) }}</span>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="tableDataTh" colspan="3" style="text-align: center">
                                        发票备注
                                    </td>
                                    <td class="tableDataTh" colspan="21">
                                        {{ dataDB.InvoiceRemark }}
                                    </td>
                                </tr>
                                <tr>
                                    <td class="tableDataTh" colspan="6" style="text-align: center">
                                        合同总额及支付阶段说明
                                    </td>
                                    <td class="tableDataTh" colspan="18">
                                        {{ dataDB.Remark }}
                                    </td>
                                </tr>
                                <tr>
                                    <td class="tableDataTh" colspan="24">
                                        <p style="font-weight: bold">
                                            注：开具专用票时，甲方单位资料一栏填写齐全并附甲方单位营业执照，一般纳税人批复复印件并附合同原件，开具普通发票时，甲方单位资料一栏只需写明单位全称及税号并附合同原件
                                        </p>
                                        <div style="margin-top: 20px;margin-bottom: 10px">
                                            <el-row>
                                                <el-col :span="8">
                                                    项目负责人
                                                </el-col>
                                                <el-col :span="8">
                                                    审批人
                                                </el-col>
                                                <el-col :span="8">
                                                    开票人
                                                </el-col>
                                            </el-row>
                                        </div>
                                    </td>
                                </tr>
                                </thead>
                            </table>
                        </div>
                    </div>
                </el-col>
            </el-row>
            <el-button style="position: fixed;right: 50px;top: 100px" type="success" size="mini"
                       v-print="printObj"><i class="el-icon-printer"></i>打印
            </el-button>
        </el-dialog>
    </div>
</template>
<script>
    import * as publicjs from '/public/Scriput/Public'
    import AuditComment from "../../AuditComment";

    export default {
        name: "FinanceInvoiceOrder",
        components: {
            'AuditComment': AuditComment
        },
        props: {
            IdNUmber: {
                type: Number,
                required: true
            },
            AllProject: {
                type: Array,
                required: true
            },

            AllDepartment: {
                type: Array,
                required: true
            },

            AllCustomer: {
                type: Array,
                required: true
            },

            OrderTableAllDB: {
                type: Object,
                required: true
            },
        },
        data() {
            return {
                detailCashier_show: false,
                detailAccount_show: false,
                AuditComment_show: false,
                printShow: false,
                dataDB: {},
                detailCashierstyle: {
                    display: "none",
                },
                Capitalion: 0,
                CapitalionChinese: '',
                imgArray: [],
                printObj: {
                    id: "wrapper",  //打印标签的id
                    popTitle: '固远晨通办公管理系统',  //文件标题
                    extraCss: 'http://www.guyuanct.com/',
                    extraHead: '<meta http-equiv="Content-Language"content="zh-cn"/>',
                    endcallback: (e) => {
                        this.wrapper.width = "80%"
                    },
                },
                // 审批弹窗返回数据
                Approval: {
                    State: 1,
                    Comment: '',
                },
                CustomerById: {},
                AllFinanceBankCard: [],
            }
        },
        created() {
            this.dataDB = this.OrderTableAllDB.obj;
            this.OrderInit();
            this.AllFinanceBankCard = publicjs.GetAllFinanceBankCard(this.$http);
            // 注入AllUsers数据
            publicjs.getAllUsers(this.$store.state.AllUsers)
            this.CustomerById = this.GetCustomer(this.dataDB.CunstomerId)
        },
        watch: {
            OrderTableAllDB: function (ids) {
                this.order();
                this.dataDB = this.OrderTableAllDB.obj;
                this.OrderInit();
                this.CustomerById = this.GetCustomer(this.dataDB.CunstomerId)
                // this.order();
            }
        },

        mounted() {
            this.order();
        },
        methods: {
            GetCompanyName() {
                this.dataDB.CompanyName = this.CustomerById.CustomerCompany;
                return this.dataDB.CompanyName;
            },
            GetDutyParagraph() {
                this.dataDB.DutyParagraph = this.CustomerById.DutyParagraph;
                return this.dataDB.DutyParagraph;
            },
            GetAddressPhone() {
                var CustomerAddress = this.CustomerById.CustomerAddress || "";
                var CustomerPhone = this.CustomerById.CustomerPhone || "";
                this.dataDB.AddressPhone = CustomerAddress + ",       " + CustomerPhone;
                return this.dataDB.AddressPhone;
            },
            GetBankName() {
                this.dataDB.BankName = this.CustomerById.OpeningBank;
                return this.dataDB.BankName;
            },
            GetBankCardNumber() {
                this.dataDB.BankCardNumber = this.CustomerById.BankAccount;
                return this.dataDB.BankCardNumber;
            },
            GetOutTax() {
                this.dataDB.OutTax = this.OrderTableAllDB.OutTax;
                return this.dataDB.OutTax;
            },
            GetTaxAmount() {
                this.dataDB.TaxAmount = this.OrderTableAllDB.TaxAmount;
                return this.dataDB.TaxAmount;
            },
            GetTotalPrice() {
                this.dataDB.TotalPrice = this.OrderTableAllDB.objTotalPrice;
                return this.dataDB.TotalPrice;
            },

            GetAllOutTax() {
                this.dataDB.AllOutTax = this.OrderTableAllDB.AllOutTax;
                return this.dataDB.AllOutTax;
            },

            GetAllTaxAmount() {
                this.dataDB.AllTaxAmount = this.OrderTableAllDB.AllTaxAmount;
                return this.dataDB.AllTaxAmount;
            },
            GetAllInTax() {
                this.dataDB.AllInTax = this.OrderTableAllDB.AllInTax;
                return this.dataDB.AllInTax;
            },

            _Arabia_To_SimplifiedChinese(obj) {
                return publicjs.Arabia_To_SimplifiedChinese(obj);
            },
            _GetAllDepartmentById(scope) {
                for (var i = 0; i < this.AllDepartment.length; i++) {
                    if (this.AllDepartment[i].Id == scope) {
                        return this.AllDepartment[i].DepartmentName;
                    }
                }
            },

            OrderInit() {
                this.InitImg();
                this.data = this.OrderTableAllDB.obj;
            },

            async InitImg() {
                this.imgArray = await publicjs.GetAllFileByUrl(this.$http, "1024," + this.dataDB.Id);
                console.log(this.imgArray);
            },

            //获取对应人员名字
            GetUserName(value) {
                let name = ''
                if (value != 0) {
                    for (let i = 0; i < this.$store.state.AllUsers.length; i++) {
                        if (this.$store.state.AllUsers[i].Id == value) {
                            name = this.$store.state.AllUsers[i].UserName
                            return name
                        }
                    }
                }
            },
            GetInvoiceType(val) {
                if (val == 1) {
                    return "增值税专用发票";
                } else if (val == 2) {
                    return "增值税普通发票";
                }
            },
            //获取对应人员名字
            GetProjectName(value) {
                let name = ''
                if (value != 0) {
                    for (let i = 0; i < this.AllProject.length; i++) {
                        if (this.AllProject[i].Id == value) {
                            name = this.AllProject[i].ProjectName
                            return name
                        }
                    }
                }
            },
            //获取对应人员名字
            GetDepartmentName(value) {
                let name = ''
                if (value != 0) {
                    for (let i = 0; i < this.AllDepartment.length; i++) {
                        if (this.AllDepartment[i].Id == value) {
                            name = this.AllDepartment[i].DepartmentName
                            return name
                        }
                    }
                }
            },
            //获取对应人员名字
            GetCustomer(value) {
                if (value != 0) {
                    var obj = this.AllCustomer.find((x) => x.Id == value);
                    return obj;
                }
            },
            //审批
            Approval_event() {
                //先置空
                if (this.rightState == 1) {
                    this.openAccountPage();
                } else if (this.rightState == 2) {
                    this.openCashierPage();
                } else {
                    this.AuditOrder();
                }
            },
            // 关闭审批结果组件
            async onClose(done) {
                await done();
                this.$refs["AuditCommentRef"].FormClose_event();
            },
            order() {
                this._AddAuditPeople(this.OrderTableAllDB.obj, 3, this.OrderTableAllDB.auditRule);
            },
            AuditOrder() {
                if (this.Approval.length == 0) {
                    return false;
                }
                let loadding = this.openLoading();
                this.$http.post('Finance/AuditFinanceInvoiceOrder', {
                    finance: this.dataDB,
                    State: this.Approval.State,
                    Comment: this.Approval.Comment,
                }).then(res => {
                    loadding.close();
                    if (res.data.IsSuccess) {
                        this._order();
                        //   this.order();
                        this.$message.success(res.data.Msg)
                    } else {
                        this.$message.warning(res.data.Msg)
                    }
                    this.AuditComment_show = false
                }).catch(() => {
                    this.$message.error('服务器异常,请联系管理员!')
                })
                this.$refs["AuditCommentRef"].FormClose_event();
            },
            _order() {
                this.$http.get('/Finance/FinanceInvoiceOrder?Id=' + this.IdNUmber).then((result) => {
                    if (result.data.mes.IsSuccess) {
                        this.OrderTableAllDB = result.data;
                    } else {
                        this.$message.error(result.data.mes.Msg)
                    }
                });
            },
            openAccountPage() {
                if (this.Approval.State == 0) {
                    this.AuditOrder();
                } else {
                    this.dataDB.ApprovalMoney = this.dataDB.Money;
                    this.detailAccount_show = true;
                }
            },

            openCashierPage() {
                if (this.Approval.State == 0) {
                    this.AuditOrder();
                } else {
                    this.detailCashier_show = true;
                }
            },
            //会计
            submitAccount() {
                if (this.dataDB.ApprovalMoney == "") {
                    this.$message.error("请输入核准金额");
                    return false;
                }
                this.detailCashier_show = false;
                this.detailAccount_show = false;
                this.AuditOrder();
            },


            //出纳
            submitCashier() {
                this.AuditOrder();
                this.detailCashier_show = false;
                this.detailAccount_show = false;
            },

            //打开审批界面
            Approval_eventShow() {
                this.AuditComment_show = true;
            },
            // 审批撤回
            withdraw() {
                console.log(this.dataDB)
                this.$confirm('您确定要撤回吗?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    if (!this.$store.state.enumDes.length) {
                        this.$message.error('数据错误,请重新登录!');
                        return
                    }
                    let Modulenumber = "";
                    for (let i = 0; i < this.$store.state.enumDes.length; i++) {
                        if (this.$store.state.enumDes[i].key === "Invoice") {
                            Modulenumber = this.$store.state.enumDes[i].value;
                            break;
                        }
                    }
                    this.$http.post("PublicMethodApi/RevokeApproveState", {
                        FormId: this.dataDB.Id,
                        Modulenumber: Modulenumber,
                    }).then(res => {
                        if (res.data.Status) {
                            this._order();
                            this.$message.success(res.data.Message)
                        } else {
                            this.$message.error(res.data.Message)
                        }
                    }).catch(() => {
                        this.$message.error('服务器异常,请联系管理员!')
                    })
                }).catch(() => {

                })
            },


            TransferMethodChange() {
                if (this.dataDB.TransferMethod == 2) {
                    this.detailCashierstyle.display = "block"
                } else {
                    this.detailCashierstyle.display = "none"
                }
            },
            _AddAuditPeople(arr, count, number) {
                publicjs.AddAuditPeople(arr, count, number);
            },

            async onPrintClick(key) {
                this.printShow = true;
                if (key === "oper") {
                    this.printObj.id = "wrapper"
                    this.order();
                } else {
                    this.printObj.id = key;
                }
            },
            async onPrintclose(done) {
                await done();
                this.printShow = false;
                this.order();
            },
            fmtDate(obj) {
                var objstr = obj.split(' ')[0];
                if (objstr != '0001-01-01') {
                    return objstr;
                } else {
                    return "";
                }
            },
        },
    }
</script>

<style scoped>
    .time {
        text-align: right;
    }

    /*外包装样式*/
    .wrapper {
        width: 80%;
        height: 100%;
        margin: auto;
    }

    /*页眉样式*/
    .header {
        font-weight: bold;
        font-size: 20px;
        font-family: cursive;
        width: 80%;
        margin: auto;
        border-bottom: 2px solid black;
        padding: 10px 0px;
        position: relative;
    }

    .header img {
        width: 200px;
        height: 55px;
    }

    .header label {
        position: absolute;
        bottom: 10px;
        right: 70px;
    }

    /*标题样式*/
    h2 {
        width: 80%;
        text-align: center;
        font-size: 25px;
        font-weight: bold;
        margin: auto;
        padding: 10px 0;
    }

    /*标题样式*/
    h4 {
        width: 80%;
        text-align: center;
        font-weight: bold;
        margin: auto;
        padding: 10px 0;
    }

    /*数据表格样式*/
    .report_data {
        width: 100%;
        text-align: center;
        border: 1px solid black;
        font-size: 14px;
        word-break: break-all;
    }

    .report_data tr {
        height: 40px;
    }

    .report_data th {
        font-weight: 100;
    }

    .baseInfo {
        height: 20px;
        line-height: 20px;
        border: 1px solid black;
        border-bottom: 0px;
        padding: 8px;
    }

    .baseInfo .worderWrapper {
        display: inline-block;
        width: 200px;
    }

    .style {
        height: 40px;
        line-height: 40px;
        border: 1px solid black;
        border-bottom: 0px;
        padding: 8px;
    }

    .price {
        border-top: none;
    }

    /*审核表格样式*/
    .report_audit {
        width: 100%;
        border: 1px solid black;
        font-size: 14px;
    }

    .report_audit .tdCenter {
        text-align: center;
    }

    .report_audit tr {
        height: 70px;
    }

    .report_audit tr p {
        padding: 3px;
    }

    .report_audit td {
        padding: 0 10px;
    }

    .report_audit td:first-child {
        width: 150px;
    }

    .report_audit .tr_center {
        text-align: center;
    }

    .audit {
        font: italic bold 20px/30px arial, sans-serif;
        text-align: right;
    }

    .audit span {
        display: inline-block;
        width: 100px;
        font: bold 17px/30px arial, sans-serif;
    }

    .author {
        width: 80%;
        margin: auto;
        margin-top: 5px;
        font-weight: bold;
        text-align: right;
    }

    /*页脚样式*/
    #Footer {
        width: 80%;
        margin: auto;
        border-top: 2px solid black;
        margin-top: 60px;
        font-weight: bold;
    }

    #Footer div {
        padding-top: 5px;
        padding-bottom: 10px;
    }

    #search select {
        text-align: left;
    }

    /*折叠面板样式修改*/
    .layui-collapse .layui-colla-title {
        margin: 0;
        width: 100%;
        text-align: left;
    }

    /*报表管理下统计报表的样式*/
    #EchartData .pie {
        height: 500px;
    }

    #EchartData .pieData {
        float: left;
        width: 50%;
        height: 500px;
    }

    #EchartData .bar {
        width: 100%;
        height: 500px;
    }

    .report_data .tr_one {
        height: 50px;
    }

    .report_data .tr_two {
        height: 100px;
    }

    .report_data .td_Title {
        font-weight: bold;
    }

    .report_data .layui-form-radio > i:hover, .report_data .layui-form-radioed > i {
        color: #5FB878 !important;
    }

    .print_border {
        border-color: red !important;
    }
</style>
